package com.itgo.codegen.bean;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

import org.apache.velocity.VelocityContext;

import com.itgo.codegen.util.StringLang;

public class TemplateBean {
	private String templateName ;
	public VelocityContext getContext(){
		VelocityContext context = new VelocityContext() ;
		context.put("strUtil", StringLang.class ) ;
		Field [] fields = this.getClass().getDeclaredFields() ;
		for( Field field : fields ){
			try{
				Method method = this.getClass().getMethod(StringLang.getMethodName(field.getName()) ) ;
				context.put( field.getName() , method.invoke( this ) ) ;
			}catch(Exception e){
				System.out.println(field.getName());
				e.printStackTrace();
			}
		}
		return context ;
	}
	public String getTemplateName() {
		return templateName;
	}
	public void setTemplateName(String templateName) {
		this.templateName = templateName;
	}
	
}
